package com.sky.controller.user;

import com.sky.pojo.Setmeal;
import com.sky.result.Result;
import com.sky.service.user.UserSetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@EnableCaching
@RestController
@RequestMapping("/user/setmeal")
public class UserSetmealController {

    @Autowired
    private UserSetmealService userSetmealService;

    /**
     * 根据分类id查询套餐
     * */
   @Cacheable(value = "setmealCache",key = "#categoryId")
    @ApiOperation("根据分类id查询套餐")
    @GetMapping("/list")
    public Result<List<Setmeal>> selectSetmeal(Integer categoryId){
        return Result.success(userSetmealService.selectSetmeal(categoryId));


    }

    /**
     * 根据套餐id查询包含的菜品
     * */
    @ApiOperation("根据套餐id查询包含的菜品")
    @GetMapping("/dish/{setmealld}")
    public Result<List<DishItemVO>> selectDishItemVO(@PathVariable Integer setmealld){


        return Result.success(userSetmealService.selectDishItemVO(setmealld));


    }



}
